package com.migu

import com.migu.streaming.OnlineUserStreaming
import com.migu.utils.ConfigUtil
import org.apache.spark.{SparkContext, SparkConf}
import org.apache.spark.streaming.{Seconds, Minutes, StreamingContext}

/**
  * Created by maguoyun on 2017/03/21.
  */
object OnlineUser {

  def main(args: Array[String]) {
    val conf = new SparkConf().setMaster("local[3]").setAppName("OnlineUserCount")
      .set("zookeeper.session.timeout.ms", "8000") //8000
      .set("zookeeper.connection.timeout.ms", "30000")
      .set("zookeeper.sync.time.ms", "2000")
      .set("rebalance.backoff.ms", "2000")
      .set("rebalance.max.retries", "10")
    //加载配置信息
    ConfigUtil.loadConfig(conf)
    //创建StreamingContext

    val ssc = new StreamingContext(conf, Minutes(5))
    //主要业务逻辑
    OnlineUserStreaming.calculate(ssc)
    ssc.start()
    ssc.awaitTermination()
}
}
